# ==================== Things `configure' will edit ====================

CC=@CC@
CFLAGS=@CFLAGS@
C_SWITCH_SYSTEM=@c_switch_system@
LOADLIBES=@LD_SWITCH_SITE@ @libsrc_libs@
C_SWITCH_SITE=@C_SWITCH_SITE@
YACC=@YACC@
version=@version@
configuration=@configuration@

# ==================== Where To Install Things ====================

# The default location for installation.  Everything is placed in
# subdirectories of this directory.  The default values for many of
# the variables below are expressed in terms of this one, so you may
# not need to change them.  This is set with the --prefix option to
# `../configure'.
prefix=@prefix@

# Like `prefix', but used for architecture-specific files.  This is
# set with the --exec-prefix option to `../configure'.
exec_prefix=@exec_prefix@

# Where to install Emacs and other binaries that people will want to
# run directly (like etags).  This is set with the --bindir option
# to `../configure'.
bindir=@bindir@

# Where to install and expect executable files to be run by Emacs
# rather than directly by users, and other architecture-dependent
# data.  ${archlibdir} is usually below this.  This is set with the
# --libdir option to `../configure'.
libdir=@libdir@

# Where to find the source code.  This is set by the configure
# script's `--srcdir' option.  However, the value of ${srcdir} in
# this makefile is not identical to what was specified with --srcdir,
# since the variable here has `/lib-src' added at the end.
srcdir=@srcdir@
VPATH=@srcdir@

# ============================= Targets ==============================

ALL_CFLAGS = ${C_SWITCH_SITE} ${C_SWITCH_SYSTEM} -Demacs -DHAVE_CONFIG_H \
   -DHAVE_STDARG_H -DHAVE_STRING_H -DHAVE_ALLOCA_H -Dxfree=free \
   -I. -I../src -I${srcdir} -I${srcdir}/../src ${CFLAGS}
CPP_CFLAGS = ${C_SWITCH_SITE} ${C_SWITCH_SYSTEM} -Demacs -DHAVE_CONFIG_H \
   -DHAVE_STDARG_H -DHAVE_STRING_H -DHAVE_ALLOCA_H -Dxfree=free \
   -I. -I../src -I${srcdir} -I${srcdir}/../src ${CPPFLAGS} ${CFLAGS}
OBJS = makeinfo.o getopt.o getopt1.o alloca.o

# Subdirectories to make recursively.
SUBDIR = xemacs lispref new-users-guide

# The makefiles of the directories in $SUBDIR.
SUBDIR_MAKEFILES = xemacs/Makefile lispref/Makefile

.c.o:
	${CC} -c ${CPP_CFLAGS} $<

../info/%.info : %.texi
	-makeinfo $<

srcs = ange-ftp cc-mode cl dired ediff evi external-widget forms gnus \
       hyperbole ilisp info ispell mailcrypt mh-e oo-browser pcl-cvs \
       rmail supercite term termcap texinfo viper vm w3 xemacs-faq standards
info = $(srcs:%=../info/%.info)

all : ${SUBDIR} $(info)

.RECURSIVE: ${SUBDIR}

xemacs: FRC.xemacs
lispref: FRC.lispref

${SUBDIR}: ${SUBDIR_MAKEFILES} makeinfo FRC
	cd $@ && $(MAKE) all $(MFLAGS) \
		CC='${CC}' CFLAGS='${CFLAGS}' MAKE='${MAKE}'

makeinfo: ../src/config.h $(OBJS)
	$(CC) -o makeinfo $(OBJS)

texindex: texindex.o
	$(CC) -o texindex texindex.o

alloca.c :
	[ -h alloca.c ] || ln -s ../src/alloca.c .

getopt.h :
	[ -h getopt.h ] || ln -s ../lib-src/getopt.h .

getopt.c :
	[ -h getopt.c ] || ln -s ../lib-src/getopt.c .

getopt1.c :
	[ -h getopt1.c ] || ln -s ../lib-src/getopt1.c .

mostlyclean: clean
	(cd xemacs &&	$(MAKE) $(MFLAGS) mostlyclean)
	(cd lispref &&	$(MAKE) $(MFLAGS) mostlyclean)

clean:
	rm -f *.dvi
	rm -f getopt1.c getopt.c getopt.h alloca.c makeinfo texindex
	rm -f *.log *.cp *.fn *.ky *.pg *.vr *.o core

# These are needed because they are present in the other makefiles.
distclean: mostlyclean
	(cd xemacs &&	$(MAKE) $(MFLAGS) distclean)
	(cd lispref &&	$(MAKE) $(MFLAGS) distclean)
	rm -f Makefile
realclean: distclean
	(cd xemacs &&	$(MAKE) $(MFLAGS) realclean)
	(cd lispref &&	$(MAKE) $(MFLAGS) realclean)
extraclean: distclean
	(cd xemacs &&	$(MAKE) $(MFLAGS) extraclean)
	(cd lispref &&	$(MAKE) $(MFLAGS) extraclean)
	-rm -f *~ \#*

makeinfo.o : getopt.h
getopt.o : getopt.h
getopt1.o : getopt.h
texindex.o : getopt.h

FRC FRC.xemacs FRC.lispref:

